home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 173 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: in1.uu.net!novia!oasis!nicatt
  2. From: nicatt@oasis.novia.net (Nicatt)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Easy but puzzling
  5. Date: 2 Jan 1996 23:37:05 GMT
  6. Organization: Novia Internetworking.
  7. Message-ID: <4ccfj1$mm1@nntp.novia.net>
  8. References: <4c4uej$a86@nntp.novia.net>
  9. NNTP-Posting-Host: oasis.novia.net
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Nicatt (nicatt@oasis.novia.net) wrote:
  13.  
  14. Thank you for the responses.  I have an answer.  Basically, I have to
  15. catch the return from the function, evaluate it, clear the buffer
  16. and prompt user again for a valid entry.
  17.  
  18. : I am new to the world of C and know I am overlooking something easy.
  19. : The last 6 hours have put me in a disagreeable mood.  Here is the
  20. : situation this rookie is in:
  21.  
  22. : I am requesting input from the user four times in a function.  In the
  23. : first two scanf's, the user must enter a numeric value from -1000 to
  24. : +1000.  The third scanf is a single digit numeric value and the fourth
  25. : scanf is an alpha character.
  26.  
  27. : Since the first three cannot be alpha characters I need to error trap alpha
  28. : entries.  I cannot get the first trap to work except for numeric values
  29. : outside the range.  How do I loop back to the scanf (to permit retries)
  30. : when the user enters alpha characters.  In essence, how do I trap them?
  31.  
  32. : I have worked "while" loops until I am blue in the face and I can not get
  33. : it to work.  I can trap the alpha character in the fourth scanf easily
  34. : since the options are only the 'f' or 'c' character.  And, as mentioned
  35. : above, I can trap numeric values outside the permitted range.
  36.  
  37. : Feel free to e-mail.
  38.  
  39. : Nicatt
  40.  
  41.  
  42.